package Class对象功能的演示;

import reflect中Class对象的创建.Person;

import java.lang.reflect.Constructor;

/**
 * @Auther:云尚学Java
 * 获取构造方法
 */
public class ReflectDemo2 {
    public static void main(String[] args) throws Exception{
        //2.类名.class:通过类名的属性class获取
        Class personClass= Person.class;
        System.out.println("2："+personClass);

        System.out.println("=============");
        //获取公有的构造方法
        Constructor constructor = personClass.getDeclaredConstructor(String.class, int.class);
        System.out.println(constructor);

        Person person = (Person) constructor.newInstance("云尚", 18);
        System.out.println(person);
    }
}
